/**
 * 服务器主文件
 *
 * @author bian
 * @createDate 2016.4.29
 */

var express = require("express");
var app = express();
var expressValidator = require('express-validator');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var server = require("http").createServer(app);
var db = require("./models/index");
var path = require("path");
app.use(express.static(path.join(__dirname,"public")));
app.use(bodyParser());
app.use(expressValidator({
    customValidators : {
        in : function(param,array){
            param  = param || "";
            return array.indexOf(param) !== -1;
        }
    }
}));
app.use(cookieParser());

var ECT = require('ect');
var ectRenderer = ECT({ root: path.join(__dirname,"/views"), ext : '.html' });

app.set('view engine', 'ect');
app.engine('html', ectRenderer.render);

var router = require("./routers/index");
app.use('/intel',router);

server.listen(5000);

module.exports = {
    server,
    app
};
//require socket.io
require("./socket/index");